home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 April: Mac OS SDK / Dev.CD Apr 98 SDK1.toast / Development Kits (Disc 1) / MacTCP / MacTCP Developer Tools / 802 LAP / LAPAsmUtil.a < prev    next >
Encoding:
Text File  |  1994-11-21  |  3.4 KB  |  207 lines  |  [TEXT/MPS ]

  1. ;********************************************************************
  2. ;    (c) Copyright 1990-91 by Apple Computer, Inc.  All rights reserved.
  3. ;
  4. ;    LAPAsmUtil.a contains various utility routines useful in writing I/O routines
  5. ;  
  6. ;********************************************************************
  7.         TITLE    'LAPAsmUtil'
  8.         CASE    OBJ
  9. ;
  10. ;    1.2        11/29/90 Rajesh    modified for IEEE 802.3 LAP
  11. ;    1.0d2    1/20/88    JEM        Convert to MPW assembler from C
  12. ;    1.0d1    9/16/87    JEM        Initial MacOS version 
  13. ;
  14.  
  15.         INCLUDE    'SysEqu.a'
  16.         INCLUDE    'Traps.a'
  17.  
  18. ;
  19. ; long GetA0()
  20. ;
  21. ; Return contents of A0 to caller
  22. ;
  23. GetA0    PROC    EXPORT
  24.         move.l a0,d0
  25.         rts
  26.         ENDPROC
  27.  
  28. ;
  29. ; long SetA0()
  30. ;
  31. ; Store contents of D0 in A0
  32. ;
  33. SetA0    PROC    EXPORT
  34. ARG1    SET        4
  35.         movem.l ARG1(sp),d0
  36.         move.l d0,a0
  37.         rts
  38.         ENDPROC
  39.  
  40. ;
  41. ; long GetA1()
  42. ;
  43. ; Return contents of A1 to caller
  44. ;
  45. GetA1    PROC    EXPORT
  46.         move.l a1,d0
  47.         rts
  48.         ENDPROC
  49.  
  50. ;
  51. ; long GetD0()
  52. ;
  53. ; Return contents of D0 to caller
  54. ;
  55. GetD0    PROC    EXPORT
  56.         move.l d0,d0
  57.         rts
  58.         ENDPROC
  59.  
  60. ;
  61. ; long SetD0()
  62. ;
  63. ; Store contents of D0 in D0
  64. ;
  65. SetD0    PROC    EXPORT
  66. ARG1    SET        4
  67.         movem.l ARG1(sp),d0
  68.         move.l d0,d0
  69.         rts
  70.         ENDPROC
  71.  
  72. ;
  73. ; long SetD1()
  74. ;
  75. ; Store contents of D0 in D1
  76. ;
  77. SetD1    PROC    EXPORT
  78. ARG1    SET        4
  79.         movem.l ARG1(sp),d0
  80.         move.l d0,d1
  81.         rts
  82.         ENDPROC
  83.  
  84. ;
  85. ; long GetD2()
  86. ;
  87. ; Return contents of D2 to caller
  88. ;
  89. GetD2    PROC    EXPORT
  90.         move.l d2,d0
  91.         rts
  92.         ENDPROC
  93.  
  94. ;
  95. ; long SetD2()
  96. ;
  97. ; Store contents of D0 in D2
  98. ;
  99. SetD2    PROC    EXPORT
  100. ARG1    SET        4
  101.         movem.l ARG1(sp),d0
  102.         move.l d0,d2
  103.         rts
  104.         ENDPROC
  105.  
  106. ;
  107. ; long GetA5()
  108. ;
  109. ; Return contents of A5 to caller
  110. ;
  111. GetA5    PROC    EXPORT
  112.         move.l a5,d0
  113.         rts
  114.         ENDPROC
  115.  
  116. ;
  117. ; long A5Swap (oldA5)
  118. ;
  119. A5Swap    PROC    EXPORT
  120. ARG1    SET        0*4 + 4
  121.         move.l    a5,d0
  122.         move.l    ARG1(sp), a5
  123.         rts
  124.         ENDPROC
  125.  
  126. ;
  127. ; void bzero(ptr, cnt)
  128. ;    char *ptr;
  129. ;    int cnt;
  130. ;
  131. ; Clear a block of memory starting from "ptr" (a0) with size "cnt" bytes (d0)
  132. ;
  133. bzero    PROC    EXPORT
  134. ARG1    SET        4
  135. ARG2    SET        ARG1+4
  136.  
  137.         move.l    ARG1(sp),a0                ;get pointer to area to zero
  138.         move.l    ARG2(sp),d0                ;and its length in bytes
  139.         bra.s    @20
  140.         
  141. @10        clr.b    (a0)+                    ;clear a byte
  142. @20        dbra    d0, @10
  143.         rts
  144.         ENDPROC
  145.  
  146.  
  147. ;
  148. ; IOComplete(ioPB)
  149. ; struct CntrlParam *ioPb;
  150. ;
  151. ; IOComplete performs the I/O completion handling on an IOP
  152. ;
  153.  
  154. IOComplete    PROC    EXPORT
  155.         movem.l    d0-d2/a0-a1, -(sp)    ;save registers
  156. ARG1    SET        5*4 + 4
  157.         move.l    ARG1(sp), a0            ;get ioPB
  158.         move.w    ioResult(a0), d0        ;get result code
  159.         cmp.w    #1, d0
  160.         bne.s    @1
  161.         pea.l    #'MacTCP--IOC w/ ioResult == 1'
  162.         _DebugStr                         
  163. @1        move.l    ioCompletion(a0), d1    ;check if I/O completion routine
  164.         beq.s    @10                        ;if not, just return
  165.         move.l    a0,-(sp)                ;push ioPB in case calling C routine
  166.         move.l    d1,a1
  167.         tst.w    d0                        ;set condition flags
  168.         jsr        (a1)                    ;call completion routine
  169.         add.l    #4,sp                    ;clean-up stack
  170. @10        movem.l    (sp)+, d0-d2/a0-a1    ;restore registers
  171.         rts
  172.         ENDPROC
  173.  
  174.  
  175. ;
  176. ; Disable();
  177. ;
  178. ; Allows procedures written in a hi-level language ("C") to
  179. ; turn off interrupts from the SCC.  This call must be balanced
  180. ; by a call to "Enable()"
  181. ;            
  182.  
  183. Disable    PROC    EXPORT    
  184. SCCLockout    EQU    $2600
  185.         moveq        #0,d0                ;return old status register
  186.         move.w        sr,d0
  187.         move.w        #SCCLockout,sr        ;disable interrupts
  188.         rts
  189.         ENDPROC
  190.  
  191. ;
  192. ; void Enable(sr)
  193. ;  int sr;
  194. ;
  195. ; Allows procedures written in a hi-level language ("C") to
  196. ; re-enable interrupts from the SCC.  This call should only
  197. ; be used to balance a previously made call to "Disable()"
  198. ;        
  199.  
  200. Enable    PROC    EXPORT
  201. ARG1    SET    4
  202.         move.l    ARG1(sp),d0
  203.         move.w  d0,sr                    ;replace status register
  204.         rts                                    
  205.         ENDPROC
  206.         END
  207.